package com.k12.edu.controller;

import com.k12.edu.entity.SchoolClassInfo;
import com.k12.edu.service.SchoolClassInfoService;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

/**
 * 学校年级班级信息表(SchoolClassInfo)表控制层
 *
 * @author makejava
 * @since 2025-08-01 11:20:14
 */
@RestController
@RequestMapping("schoolClassInfo")
public class SchoolClassInfoController {
    /**
     * 服务对象
     */
    @Resource
    private SchoolClassInfoService schoolClassInfoService;

    /**
     * 分页查询
     *
     * @param schoolClassInfo 筛选条件
     * @param pageRequest      分页对象
     * @return 查询结果
     */
    @GetMapping
    public List<SchoolClassInfo> queryByPage(SchoolClassInfo schoolClassInfo) {
        return this.schoolClassInfoService.queryByPage(schoolClassInfo);
    }

    /**
     * 通过主键查询单条数据
     *
     * @param id 主键
     * @return 单条数据
     */
    @GetMapping("{id}")
    public SchoolClassInfo queryById(@PathVariable("id") Integer id) {
        return this.schoolClassInfoService.queryById(id);
    }

    /**
     * 新增数据
     *
     * @param schoolClassInfo 实体
     * @return 新增结果
     */
    @PostMapping
    public SchoolClassInfo add(SchoolClassInfo schoolClassInfo) {
        return this.schoolClassInfoService.insert(schoolClassInfo);
    }

    /**
     * 编辑数据
     *
     * @param schoolClassInfo 实体
     * @return 编辑结果
     */
    @PutMapping
    public SchoolClassInfo edit(SchoolClassInfo schoolClassInfo) {
        return this.schoolClassInfoService.update(schoolClassInfo);
    }

    /**
     * 删除数据
     *
     * @param id 主键
     * @return 删除是否成功
     */
    @DeleteMapping
    public Boolean deleteById(Integer id) {
        return this.schoolClassInfoService.deleteById(id);
    }

}

